/**
 * @param {number[]} prices
 * @return {number}
 */
function maxProfit(prices) {
    let res = 0
    for (let i = 0, len = prices.length - 1; i < len; i++) {
        res += Math.max(prices[i + 1] - prices[i], 0)
    }
    return res
}
let res = maxProfit([7, 1, 5, 3, 6, 4])
console.log(res)